package com.dong.c03_channel;

import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;

/**
 * <h1></h1>
 *  总结就是放啥 取啥   ,  否则报异常 {@link BufferUnderflowException}
 * @author : dzj
 * @create: 2020-03-17 23:42
 */
public class P5_NioBytebufferPutGet {
    public static void main(String[] args) {
        ByteBuffer buffer = ByteBuffer.allocate(64);
        buffer.putInt(100);
        buffer.putLong(9L);
        buffer.putChar('尚');
        buffer.putShort((short)4);
        buffer.flip();
        System.out.println(buffer.getInt());
        System.out.println(buffer.getLong());
        System.out.println(buffer.getChar());
        System.out.println(buffer.getShort());
    }
}
